/******************************************************************************
 * Copyright (C) 2024 EternalChip, Inc.(Gmbh) or its affiliates.
 *
 * All Rights Reserved.
 *
 * @file BSP_Key.c
 *
 * @par dependencies
 * - bsp_key.h
 *
 * @author BOAT | EternalChip 立芯嵌入式
 *
 * @brief Provide the HAL APIs of Key and corresponding options.
 *
 * Processing flow:
 *
 * call directly.
 *
 * @version V1.0 2024-11-17
 *
 * @note 1 tab == 4 spaces!
 *
 *****************************************************************************/

#include "BSP_KEY.h"

key_status_t Key_Scan(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) {
    if (GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOx, GPIO_Pin)) {
        vTaskDelay(pdMS_TO_TICKS(20));
        while (GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOx, GPIO_Pin));
        return KEY_PRESS;
    } else
        return KEY_RELEASE;
}
